#include <bits/stdc++.h>

#define x first
#define y second
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int T, n, m, k, ans;

map<PII, int> mp1;
map<PII, int> mp2;

double get_dist(PII a, PII b)
{
	double dx = a.x - b.x;
	double dy = a.y - b.y;
	return sqrt(dx * dx + dy * dy);
}

struct Node
{
	int a, b, c;
	void init(int _a, int _b, int _c)
	{
		a = _a;
		b = _b;
		c = _c;
	}	
};

void bfs(int a, int b, int c)
{
	queue<Node> q;
	
	Node tt;
	tt.init(a, b, c);
	
	q.push(tt);
	
	while (q.size())
	{
		Node t = q.front(); q.pop();
		
		PII ts = make_pair(t.a, t.b);
		
		for (int i = t.a - t.c; i <= t.a + t.c; i ++ )
			for (int j = t.b - t.c; j <= t.b + t.c; j ++ )
			{
				PII ttt = make_pair(i, j);
				
		
				if (mp1.count(ttt) && get_dist(ts, ttt) <= t.c)
				{
					ans += mp1[ttt];
					
					Node __;
					__.init(i, j, mp2[ttt]);
					
					mp1.erase(ttt);
					mp2.erase(ttt);
					
					q.push(__);
				}
			}
	}
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed <<  setprecision(0);
	
	cin >> n >> m;
	
	for (int i = 1; i <= n; i ++ )
	{	
		int a, b, c;
		cin >> a >> b >> c;
		PII t = make_pair(a, b);
		mp1[t] ++;
		mp2[t] = max(c, mp2[t]);
	}
	
	while (m -- )
	{
		int a, b, c;
		cin >> a >> b >> c;
		
		bfs(a, b, c);
	}
	
	cout << ans << endl;
	
    return 0;
}